package br.com.jk.financeiro.movimentotipo;

import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * "Teste de alteração"
 *
 * @author camilo
 */
@Entity
@Table(name = MovimentoTipoDao.NAME_TABLE, schema = MovimentoTipoDao.NAME_SCHEMA, uniqueConstraints =
        @UniqueConstraint(name = "uk_descricao", columnNames = MovimentoTipoDao.NAME_COLUMN_DESCRICAO))
public class MovimentoTipo implements Serializable {

  public static final String ATTRIBUTE_ID = "id";
  public static final String ATTRIBUTE_TIPO = "tipo";
  public static final String ATTRIBUTE_DESCRICAO = "descricao";
  public static final String ATTRIBUTE_IS_CHEQUE = "isCheque";
  public static final String ATTRIBUTE_REQUEST_NUMBER = "requestNumber";
  public static final String ATTRIBUTE_REQUEST_ENTITY = "requestEntity";
  public static final String ATTRIBUTE_REQUEST_PREVISION = "requestPrevision";

  public enum Tipo {

    ENTRADA(1), SAIDA(-1);
    private final int valor;

    Tipo(int valorOpcao) {
      valor = valorOpcao;
    }

    public int getValor() {
      return valor;
    }
  }
  @Id
  @SequenceGenerator(name = MovimentoTipoDao.NAME_SEQUENCE, sequenceName = MovimentoTipoDao.NAME_SEQUENCE,
          schema = MovimentoTipoDao.NAME_SCHEMA)
  @GeneratedValue(strategy = GenerationType.AUTO, generator = MovimentoTipoDao.NAME_SEQUENCE)
  private int id;
  @Column(name = MovimentoTipoDao.NAME_COLUMN_TIPO, nullable = false)
  private Tipo tipo;
  @Column(name = MovimentoTipoDao.NAME_COLUMN_DESCRICAO, nullable = false)
  private String descricao;
  @Column(name = MovimentoTipoDao.NAME_COLUMN_IS_CHEQUE)
  private Boolean isCheque;
  @Column(name = MovimentoTipoDao.NAME_COLUMN_REQUEST_NUMBER)
  private Boolean requestNumber;
  @Column(name = MovimentoTipoDao.NAME_COLUMN_REQUEST_ENTITY)
  private Boolean requestEntity;
  @Column(name = MovimentoTipoDao.NAME_COLUMN_REQUEST_PREVISION)
  private Boolean requestPrevision;

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public Tipo getTipo() {
    return tipo;
  }

  public void setTipo(Tipo tipo) {
    this.tipo = tipo;
  }

  public String getDescricao() {
    return descricao;
  }

  public void setDescricao(String descricao) {
    this.descricao = descricao;
  }

  public Boolean getIsCheque() {
    return isCheque;
  }

  public void setIsCheque(Boolean isCheque) {
    this.isCheque = isCheque;
  }

  public Boolean getRequestNumber() {
    return requestNumber;
  }

  public void setRequestNumber(Boolean requestNumber) {
    this.requestNumber = requestNumber;
  }

  public Boolean getRequestEntity() {
    return requestEntity;
  }

  public void setRequestEntity(Boolean requestEntity) {
    this.requestEntity = requestEntity;
  }

  public Boolean getRequestPrevision() {
    return requestPrevision;
  }

  public void setRequestPrevision(Boolean requestPrevision) {
    this.requestPrevision = requestPrevision;
  }

  @Override
  public int hashCode() {
    int hash = 7;
    hash = 23 * hash + this.id;
    hash = 23 * hash + Objects.hashCode(this.tipo);
    hash = 23 * hash + Objects.hashCode(this.descricao);
    hash = 23 * hash + Objects.hashCode(this.isCheque);
    hash = 23 * hash + Objects.hashCode(this.requestNumber);
    hash = 23 * hash + Objects.hashCode(this.requestEntity);
    hash = 23 * hash + Objects.hashCode(this.requestPrevision);
    return hash;
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    final MovimentoTipo other = (MovimentoTipo) obj;
    if (this.id != other.id) {
      return false;
    }
    if (this.tipo != other.tipo) {
      return false;
    }
    if (!Objects.equals(this.descricao, other.descricao)) {
      return false;
    }
    if (!Objects.equals(this.isCheque, other.isCheque)) {
      return false;
    }
    if (!Objects.equals(this.requestNumber, other.requestNumber)) {
      return false;
    }
    if (!Objects.equals(this.requestEntity, other.requestEntity)) {
      return false;
    }
    if (!Objects.equals(this.requestPrevision, other.requestPrevision)) {
      return false;
    }
    return true;
  }
}
